package com.music.server.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.music.server.pojo.Admin;
import com.music.server.mapper.AdminMapper;
import com.music.server.service.AdminService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 管理员 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2021-03-05
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

    @Override
    public Map<String, Object> login(Admin admin) {
        QueryWrapper<Admin> queryWrapper  = new QueryWrapper<>();
        queryWrapper.eq("name",admin.getName());
        Map<String,Object> map = new HashMap<>();
        Admin loginAdmin = this.getOne(queryWrapper);
        if (loginAdmin==null) {
            map.put("status","error");
            map.put("meg","用户名输入错误！！");
            return map;
        }
        if (!loginAdmin.getPassword().equals(admin.getPassword())){
            map.put("status","error");
            map.put("meg","密码输入错误！！");
            return map;
        }
        map.put("status","succee");
        map.put("meg","登录成功！！");
        return map;
    }
}
